﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.StorageClient;
using System.Data.Services.Common;
using System.ComponentModel.DataAnnotations;

namespace LCA.Community.DAL.Model
{
    /// <summary>
    /// This is the basic model that has to be inherited by the rest of the data models.
    /// </summary>
    [DataServiceKey(new[] { "PartitionKey", "RowKey" })]
    [CLSCompliant(false)]
    public class BasicDataModel
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicDataModel"/> class.
        /// </summary>
        public BasicDataModel()
        {

        }

        /// <summary>
        /// Equalses the specified obj.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns><c>true</c> if both objects are equals; otherwise, <c>false</c>.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            var u = obj as BasicDataModel;
            if ((System.Object)u == null)
            {
                return false;
            }

            return RowKey.Equals(u.RowKey) && PartitionKey.Equals(u.PartitionKey);
        }

        /// <summary>
        /// Gets the hash code.
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        #region Properties
        /// <summary>
        /// Gets or sets the partition key.
        /// </summary>
        /// <value>
        /// The partition key.
        /// </value>
        virtual public string PartitionKey { get; set; }
        /// <summary>
        /// Gets or sets the row key.
        /// </summary>
        /// <value>
        /// The row key.
        /// </value>
        virtual public string RowKey { get; set; }
        /// <summary>
        /// Gets or sets the time stamp.
        /// </summary>
        /// <value>
        /// The time stamp.
        /// </value>
        public DateTime Timestamp { get; set; } 
        #endregion
    }
}
